package com.aaa.a1103.demo04;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author 荆豪峰
 * @version 1.0
 */
public class Test04 {
    public static void main(String[] args) {
        List<Student> list=new ArrayList<>();
        list.add(new Student("洛天依",16));
        list.add(new Student("迪亚波罗",36));
        list.add(new Student("剑魔",1500));
        list.add(new Student("埼玉",25));

        Comparator<Student> comparator=(o, o1)->{return o.getAge()-o1.getAge();};
        Collections.sort(list,comparator);
        System.out.println(list);
    }
}
class Student{
    private String name;
    private Integer age;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Student(String name, Integer age) {
        this.name = name;
        this.age = age;
    }
}
